/*     */ package cc.s2m.web.s2mBlog.controller.admin;
/*     */ 
/*     */ import cc.s2m.util.BeanConverter;
/*     */ import cc.s2m.util.Page;
/*     */ import cc.s2m.web.s2mBlog.controller.base.BaseController;
/*     */ import cc.s2m.web.s2mBlog.pojo.AdminActions;
/*     */ import cc.s2m.web.s2mBlog.pojo.AdminRoleActions;
/*     */ import cc.s2m.web.s2mBlog.pojo.Roles;
/*     */ import cc.s2m.web.s2mBlog.service.IAdminActions;
/*     */ import cc.s2m.web.s2mBlog.service.IAdminRoleActions;
/*     */ import cc.s2m.web.s2mBlog.service.IRoles;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.ui.Model;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ import org.springframework.web.bind.annotation.ResponseBody;
/*     */ 
/*     */ @Controller("admin_RolesController")
/*     */ @RequestMapping({"/admin/roles"})
/*     */ public class RolesController extends BaseController
/*     */ {
/*     */ 
/*     */   @Autowired
/*     */   private IRoles rolesService;
/*     */ 
/*     */   @Autowired
/*     */   private IAdminActions adminActionsService;
/*     */ 
/*     */   @Autowired
/*     */   private IAdminRoleActions adminRoleActionsService;
/*     */ 
/*     */   @RequestMapping({"/list"})
/*     */   public String list(Model model, Roles bean, Integer page)
/*     */   {
/*  36 */     if (page == null) page = Integer.valueOf(1);
/*  37 */     Map map = new HashMap();
/*  38 */     if (bean != null) {
/*  39 */       map.putAll(BeanConverter.toMap(bean, false));
/*  40 */       model.addAttribute("bean", bean);
/*     */     }
/*  42 */     Page pageBean = this.rolesService.getPage(page.intValue(), 2147483647, null, map);
/*  43 */     model.addAttribute("pageBean", pageBean);
/*  44 */     return "admin/roles";
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"/add"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public String add(Model model, Integer id) {
/*  49 */     if (id != null) {
/*  50 */       Roles bean = (Roles)this.rolesService.selectByPrimaryKey(id);
/*  51 */       model.addAttribute("bean", bean);
/*     */ 
/*  53 */       AdminRoleActions condition = new AdminRoleActions();
/*  54 */       condition.setRid(id);
/*  55 */       List myActions = this.adminRoleActionsService.getList(condition, null);
/*  56 */       model.addAttribute("myActions", myActions);
/*     */     }
/*     */ 
/*  59 */     Map map = new HashMap();
/*  60 */     map.put("orderBy", "paixu ASC");
/*  61 */     List actions = this.adminActionsService.getList(new AdminActions(), map);
/*  62 */     model.addAttribute("actions", actions);
/*  63 */     return "admin/roles_add";
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"/view"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public String view(Model model, Integer id) {
/*  68 */     if (id != null) {
/*  69 */       Roles bean = (Roles)this.rolesService.selectByPrimaryKey(id);
/*  70 */       model.addAttribute("bean", bean);
/*     */     }
/*  72 */     return "admin/roles_view";
/*     */   }
/*     */   @RequestMapping(value={"/save"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   @ResponseBody
/*     */   public String save(Model model, Roles bean, Integer[] actionsIds) {
/*  78 */     if (bean == null) {
/*  79 */       return "empty";
/*     */     }
/*  81 */     if (bean.getId() == null)
/*     */     {
/*  83 */       this.rolesService.insertSelective(bean);
/*     */     }
/*     */     else {
/*  86 */       this.rolesService.updateByPrimaryKeySelective(bean);
/*     */ 
/*  88 */       AdminRoleActions condition = new AdminRoleActions();
/*  89 */       condition.setRid(bean.getId());
/*  90 */       this.adminRoleActionsService.delete(condition, null);
/*     */     }
/*     */ 
/*  93 */     if ((actionsIds != null) && (actionsIds.length > 0)) {
/*  94 */       for (Integer actionId : actionsIds) {
/*  95 */         AdminRoleActions roleAction = new AdminRoleActions();
/*  96 */         roleAction.setAid(actionId);
/*  97 */         roleAction.setRid(bean.getId());
/*  98 */         this.adminRoleActionsService.insertSelective(roleAction);
/*     */       }
/*     */     }
/* 101 */     return "success";
/*     */   }
/*     */   @RequestMapping(value={"/del"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   @ResponseBody
/*     */   public String del(Integer id) {
/* 107 */     Roles bean = (Roles)this.rolesService.selectByPrimaryKey(id);
/* 108 */     if (bean != null) {
/* 109 */       this.rolesService.deleteByPrimaryKey(id);
/*     */ 
/* 111 */       AdminRoleActions condition = new AdminRoleActions();
/* 112 */       condition.setRid(id);
/* 113 */       this.adminRoleActionsService.delete(condition, null);
/*     */     }
/* 115 */     return "success";
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\s2mBlog.zip
 * Qualified Name:     s2mBlog-3.0.0.WEB-INF.classes.cc.s2m.web.s2mBlog.controller.admin.RolesController
 * JD-Core Version:    0.6.1
 */